<?php
/***
 * I'd really like a better way, what we really want is a reverse tree.
 * we could also possibly split this file to lower the amount included per page
 * depending on how we handle this, we could also place it in config.php
 **/
$nav = '__NAV_TPL';
$util = '__NAV_UTIL';
$dbput = '__NAV_DB_PUT';
$dbget = '__NAV_DB_GET';
$handle = '__NAV_HANDLE';
$view = '__NAV_VIEW';

// XXX THIS SHOULD CHANGE PATHS
// right now it's only pointing to settings, because I don't want to
// create a seperate file. However, it should contain paths info.
$__PDATA = parse_ini_file('../path.ini',1);

function modpath($type, $file) {
  global $nav;
  global $util;
  global $dbput;
  global $dbget;
  global $handle;
  global $view;

  global $__PDATA;

  switch( $type ) {
    case 'tpl':
      $mod = $GLOBALS[$nav][$file];
      if( $mod ) 
        $mod .= DIRECTORY_SEPARATOR; 
      return $__PDATA['TPL_DIR'] . DIRECTORY_SEPARATOR . $__PDATA['STYLE_NAME'] . DIRECTORY_SEPARATOR . $mod . $file . $__PDATA['STYLE_FILE_TYPE'];
      break;
    case 'util':
      return $__PDATA['UTIL_DIR']. DIRECTORY_SEPARATOR .$GLOBALS[$util][$file]. DIRECTORY_SEPARATOR .$file.$__PDATA['PHP_FILE_TYPE'];
      break;
    case 'dbget':
      return $__PDATA['DB_DIR']. DIRECTORY_SEPARATOR .$GLOBALS['__DBTYPE']. DIRECTORY_SEPARATOR 
                               . $__PDATA['DB_GET_DIR']. DIRECTORY_SEPARATOR .$GLOBALS[$dbget][$file].DIRECTORY_SEPARATOR.$file.$__PDATA['PHP_FILE_TYPE'];
      break;
    case 'dbput':
      return $__PDATA['DB_DIR']. DIRECTORY_SEPARATOR .$GLOBALS['__DBTYPE']. DIRECTORY_SEPARATOR 
                               . $__PDATA['DB_PUT_DIR']. DIRECTORY_SEPARATOR .$GLOBALS[$dbput][$file].DIRECTORY_SEPARATOR.$file.$__PDATA['PHP_FILE_TYPE'];
      break;
    case 'handle':
      return $__PDATA['HANDLE_DIR']. DIRECTORY_SEPARATOR .$GLOBALS[$handle][$file]. DIRECTORY_SEPARATOR .$file.$__PDATA['PHP_FILE_TYPE'];
      break;
    case 'view':
      return $__PDATA['VIEW_DIR']. DIRECTORY_SEPARATOR .$GLOBALS[$view][$file]. DIRECTORY_SEPARATOR .$file.$__PDATA['PHP_FILE_TYPE'];
      break;
    default:
      echo 'linkerr';
      break;
  }
}

$GLOBALS[ $nav ] = array(
  "Unauthorized"=>"glitch",

  "Fora"=>"fora",

  ""=>""
);
$GLOBALS[ $util ] = array(
  "bitter"=>"fora",
  "captcha"=>"fora",
  "lsi"=>"fora",
  "mail"=>"fora",
  "math"=>"fora",
  "matrix"=>"fora",
  "msg"=>"fora",
  "smurfs"=>"fora",
  "timer"=>"fora",
  "redirect"=>"fora",

  "user"=>"user",
  "perm"=>"user",
  "auth"=>"user",


  ""=>""
);
$GLOBALS[ $dbput ] = array(
  "forum"=>"fora",
  "post"=>"fora",
  "thread"=>"fora",

  "user"=>"user",


  ""=>""
);
$GLOBALS[ $dbget ] = array(
  "forum"=>"fora",
  "post"=>"fora",
  "thread"=>"fora",

  "user"=>"user",


  ""=>""
);
$GLOBALS[ $view ] = array(
  "blog"=>"fora",
  "edit_post"=>"fora",
  "fora"=>"fora",
  "new_post"=>"fora",
  "post"=>"fora",
  "static"=>"fora",
  "thread"=>"fora",

  "login"=>"user",
  "register"=>"user",
  "user"=>"user",


  ""=>""
);
$GLOBALS[ $handle ] = array(
  "admin"=>"fora",
  "edit"=>"fora",
  "forum"=>"fora",
  "post"=>"fora",
  "thread"=>"fora",

  "login"=>"user",
  "logout"=>"user",
  "register"=>"user",

  ""=>""
);
?>
